<?php
class Planesmejoramiento_Form_Actividadesplan extends Form_Base{
	
	public function __construct($options = null) {
		parent::__construct($options);
	}
	
	public function init() {
		$this->setName('actividadesplan');
		$this->setMethod("post");
		$this->setAttrib('enctype', 'multipart/form-data');
		$domConfig = Zend_Registry::get('domConfig');
		
		$array_elements[] = new Zend_Form_Element_Hidden("codactividad");
		$array_elements[] = new Zend_Form_Element_Hidden("codplanmejoramiento");
		
		$element = new Zend_Form_Element_Text("nombre");
	    $element->setLabel("Nombre de la actividad : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
        $array_elements[] = $element;
       
       
        $element = new App_Form_Element_Datepicker('fechainicio',false);
		$element->setLabel('Fecha inicio :');
		$element->setRequired(true);
		$element->setAttrib("readonly","readonly");
		$array_elements[] = $element;

		$element = new App_Form_Element_Datepicker('fechafin',false);
		$element->setLabel('Fecha fin :');
		$element->setRequired(true);
		$element->setAttrib("readonly","readonly");
		$array_elements[] = $element;
        
        $element = new Zend_Form_Element_Text("peso");
	    $element->setLabel("Peso de la actividad : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
	    $element->addValidator(new Zend_Validate_Digits());
	    $element->setAttribs(array('size'=>10));
        $array_elements[] = $element;
        
        $element = new Zend_Form_Element_Text("indicador");
	    $element->setLabel("Indicador : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
        $array_elements[] = $element;
                
        $element = new Zend_Form_Element_Text("responsable");
	    $element->setLabel("Responsable : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
        $array_elements[] = $element;

        $element = new Zend_Form_Element_Text("cargo");
	    $element->setLabel("Cargo : ");
	    $element->setRequired(true);
	    $element->addFilter('StripTags');
	    $element->addFilter('StringTrim');
//	    $element->addFilter('StringToUpper');
        $array_elements[] = $element;
                
		$element = new Zend_Form_Element_Textarea('meta');
		$element->setLabel('Meta :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",3);
		$element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
        $array_elements[] = $element;
                
		$element = new Zend_Form_Element_Textarea('descripcion');
		$element->setLabel('Descripción :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",3);
		$element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
        $array_elements[] = $element;
        
		$element = new Zend_Form_Element_Textarea('recursos');
		$element->setLabel('Recursos :');
		$element->setRequired(true);
		$element->addFilter('StripTags');
		$element->addFilter('StringTrim');
//		$element->addFilter('StringToUpper');
		$element->setAttrib("rows",3);
		$element->addValidator('StringLength', false, array($domConfig->TEXTO_TAMANOMIN));
		$array_elements[] = $element;
		
        $element = new Zend_Form_Element_Text("costo");
        $element->setLabel("$ costo : ");
        $element->setRequired(true);
        $element->addFilter('StripTags');
        $element->addFilter('StringTrim');
        $element->addValidator(new Zend_Validate_Float(new Zend_Locale("en_US")));
        $element->addValidator(new Zend_Validate_GreaterThan(0));
        $elements[] = $element;
		
		$appConfig = Zend_Registry::get('appConfig');
		$element = new Zend_Form_Element_File('archivo');
		$element->setLabel('Adjuntar archivo :');
        $element->setMaxFileSize(10485760);
		$element->addValidator('Size', false, 10485760); // 10MB = 10,485,760 bytes
		$element->setDestination($appConfig->get("ruta_archivos"));
//        $archivo->setRequired(true);
        $element->setValueDisabled(true);
        $element->addValidator('Extension', false, $domConfig->EXTENSIONES_ARCHIVOS);
        $element->addValidator('Count', false, 1);
		$array_elements[] = $element;
		
		$element = new Zend_Form_Element_Submit ( 'btnSubmit' );
		$element->setValue('Guardar');
		$element->setLabel("Guardar");
		$element->setAttrib("class", "iceCmdBtn");
		$element->setDescription($this->createCommandLink("Cancelar", "/planesmejoramiento/index/actividadesplan", "Regresar a la lista"));
		$array_elements[] = $element;
		
		$this->addElements ($array_elements);
		
		$this->loadTableDecorators();
	}
	
}